package mainControlsTest;

import junit.framework.TestCase;
import mainControls.LectureChecker;
import smallTools.SimpleTime;
import entities.AcdcProgram;
import entities.Course;
import entities.Room;
import entities.Section;
import entities.Staff;

public class LectureCheckerTest extends TestCase {
	private LectureChecker m_lectureChecker;

	public void setUp() {
		m_lectureChecker = new LectureChecker();
	}

	public void tearDown() {
		Room.clear();
		Section.clear();
		Staff.clear();
		Course.clear();
		AcdcProgram.clear();
	}

	public void test_returnTrueImmediately() {
		Section section1 = new Section("CS1_T01", 40, 2, null);
		Course course1 = new Course("CS1", new String[0]);
		course1.addTutorial("CS1_T01");

		boolean result = m_lectureChecker.check(section1, course1,
				new SimpleTime("Mon", 11, 30));
		assertEquals(true, result);
	}

	public void test_OneIteration() {
		Section sectionC1 = new Section("CS1_C01", 40, 2, null);
		Section sectionC2 = new Section("CS1_C02", 40, 2, null);
		Course course1 = new Course("CS1", new String[0]);
		course1.addLecture("CS1_C01");
		course1.addLecture("CS1_C02");

		sectionC1.setSectionStartTime(new SimpleTime("Mon", 11, 30));

		boolean result = m_lectureChecker.check(sectionC2, course1,
				new SimpleTime("Mon", 11, 30));
		assertEquals(false, result);
	}

	public void test_TwoIteration() {
		Section sectionC1 = new Section("CS1_C01", 40, 2, null);
		Section sectionC2 = new Section("CS1_C02", 40, 2, null);
		Section sectionC3 = new Section("CS1_C03", 40, 2, null);
		Course course1 = new Course("CS1", new String[0]);
		course1.addLecture("CS1_C01");
		course1.addLecture("CS1_C02");
		course1.addLecture("CS1_C03");

		sectionC1.setSectionStartTime(new SimpleTime("Mon", 11, 30));
		sectionC2.setSectionStartTime(new SimpleTime("Tue", 11, 30));

		boolean result = m_lectureChecker.check(sectionC3, course1,
				new SimpleTime("Tue", 11, 30));
		assertEquals(false, result);
	}
}
